package com.pq.service.impl;

import com.pq.dao.user.UserDao;
import com.pq.pojo.user.User;
import com.pq.service.user.UserService;
import com.pq.utils.ObjectMapperUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.UUID;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Autowired
    private Jedis jedis;
    @Override
    public int doRegister(String userName, String userPhone, String userPassword) {
        return userDao.doRegister(userName,userPhone,userPassword);
    }

    @Override
    public User doLoginFind(String userName, String userPassword) {
        if (!StringUtils.hasLength(userName)||!StringUtils.hasLength(userPassword))
            throw new IllegalArgumentException("用户名或密码不能为空");
        User user=userDao.doLoginFind(userName);
        if (userPassword.equals(user.getUserPassword())){
            return user;
        }
        return null;
    }

    @Override
    public User getUserName(String username) {
        return userDao.doLoginFind(username);
    }


}
